package kr.co.doriclassic.dataEx;

import java.util.Arrays;

public class Queue implements Data{
	private String arrItem[];
	private int front;
	private int real;
	private int size;
	
	public Queue(int size) {
		this.size = size;
		this.arrItem = new String[size];
		this.real = -1;	
		this.front = 0;
	}
	@Override
	public void push(String item){
		if(!isFull()){
			arrItem[++real]=item;
		}
		else{
			System.out.println("Queu is Full");			
		}
	}
	@Override
	public String pop(){
		if(!isEmpty()){
			return arrItem[front++];			
		}
		else{
			return "Queu is Empty";
		}	
	}

	@Override
	public boolean isEmpty(){
		return front==(real+1);
	}
	public boolean isFull(){		
		return real==(size-1);
	}

	@Override
	public void prnStack(){
		for (int i = front; i <= real; i++) {
			System.out.printf("[%s\t]",arrItem[i]);			
		}
		System.out.println();
	}

	@Override
	public String toString() {
		return String.format("%s\n",Arrays.toString(arrItem));
	}		
}
